home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 401-425 / disk_407 / flex / src.lzh / src / main.c < prev    next >
C/C++ Source or Header  |  1990-07-14  |  20KB  |  785 lines

  1. /* flex - tool to generate fast lexical analyzers */
  2.  
  3. /*-
  4.  * Copyright (c) 1990 The Regents of the University of California.
  5.  * All rights reserved.
  6.  *
  7.  * This code is derived from software contributed to Berkeley by
  8.  * Vern Paxson.
  9.  * 
  10.  * The United States Government has rights in this work pursuant
  11.  * to contract no. DE-AC03-76SF00098 between the United States
  12.  * Department of Energy and the University of California.
  13.  *
  14.  * Redistribution and use in source and binary forms are permitted provided
  15.  * that: (1) source distributions retain this entire copyright notice and
  16.  * comment, and (2) distributions including binaries display the following
  17.  * acknowledgement:  ``This product includes software developed by the
  18.  * University of California, Berkeley and its contributors'' in the
  19.  * documentation or other materials provided with the distribution and in
  20.  * all advertising materials mentioning features or use of this software.
  21.  * Neither the name of the University nor the names of its contributors may
  22.  * be used to endorse or promote products derived from this software without
  23.  * specific prior written permission.
  24.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  25.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  26.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27.  */
  28.  
  29. #ifndef lint
  30. char copyright[] =
  31. "@(#) Copyright (c) 1990 The Regents of the University of California.\n\
  32.  All rights reserved.\n";
  33. #endif /* not lint */
  34.  
  35. #ifndef lint
  36. static char rcsid[] =
  37.     "@(#) $Header: WPL:Generators/flex-2.3/RCS/main.c,v 1.2 90/07/15 01:17:37 loftus Exp $ (LBL)";
  38. #endif
  39.  
  40.  
  41. #include "flexdef.h"
  42.  
  43. static char flex_version[] = "2.3";
  44.  
  45.  
  46. /* declare functions that have forward references */
  47.  
  48. void flexinit PROTO((int, char**));
  49. void readin PROTO(());
  50. void set_up_initial_allocations PROTO(());
  51.  
  52.  
  53. /* these globals are all defined and commented in flexdef.h */
  54. int printstats, syntaxerror, eofseen, ddebug, trace, spprdflt;
  55. int interactive, caseins, useecs, fulltbl, usemecs;
  56. int fullspd, gen_line_dirs, performance_report, backtrack_report, csize;
  57. int yymore_used, reject, real_reject, continued_action;
  58. int yymore_really_used, reject_really_used;
  59. int datapos, dataline, linenum;
  60. FILE *skelfile = NULL;
  61. char *infilename = NULL;
  62. int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
  63. int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
  64. int current_mns, num_rules, current_max_rules, lastnfa;
  65. int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
  66. int *accptnum, *assoc_rule, *state_type, *rule_type, *rule_linenum;
  67. int current_state_type;
  68. int variable_trailing_context_rules;
  69. int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP];
  70. int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE];
  71. int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs, tecfwd[CSIZE + 1];
  72. int tecbck[CSIZE + 1];
  73. int *xlation = (int *) 0;
  74. int num_xlations;
  75. int lastsc, current_max_scs, *scset, *scbol, *scxclu, *sceof, *actvsc;
  76. char **scname;
  77. int current_max_dfa_size, current_max_xpairs;
  78. int current_max_template_xpairs, current_max_dfas;
  79. int lastdfa, *nxt, *chk, *tnxt;
  80. int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz;
  81. union dfaacc_union *dfaacc;
  82. int *accsiz, *dhash, numas;
  83. int numsnpairs, jambase, jamstate;
  84. int lastccl, current_maxccls, *cclmap, *ccllen, *cclng, cclreuse;
  85. int current_max_ccl_tbl_size;
  86. Char *ccltbl;
  87. char *starttime, *endtime, nmstr[MAXLINE];
  88. int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
  89. int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
  90. int num_backtracking, bol_needed;
  91. FILE *temp_action_file;
  92. FILE *backtrack_file;
  93. int end_of_buffer_state;
  94. char *action_file_name = NULL;
  95. char **input_files;
  96. int num_input_files;
  97. char *program_name;
  98.  
  99. #ifndef SHORT_FILE_NAMES
  100. static char *outfile = "lex.yy.c";
  101. #else
  102. static char *outfile = "lexyy.c";
  103. #endif
  104. static int outfile_created = 0;
  105. static int use_stdout;
  106. static char *skelname = NULL;
  107.  
  108. #ifdef AMIGA
  109. char *                                                                         
  110. TmpFileName(template)                                                          
  111. char *template;                                                                
  112. {                                                                              
  113.     static char Template[256];                                                 
  114.     static unsigned short Idx;                                                 
  115.                                                                                
  116.     sprintf(Template, "%s-%08lx.TMP", template, (long)FindTask(NULL) + Idx++); 
  117.     return(Template);                                                          
  118. }
  119. #endif
  120.  
  121.  
  122. int main( argc, argv )
  123. int argc;
  124. char **argv;
  125.  
  126.     {
  127.     flexinit( argc, argv );
  128.  
  129.     readin();
  130.  
  131.     if ( syntaxerror )
  132.     flexend( 1 );
  133.  
  134.     if ( yymore_really_used == REALLY_USED )
  135.     yymore_used = true;
  136.     else if ( yymore_really_used == REALLY_NOT_USED )
  137.     yymore_used = false;
  138.  
  139.     if ( reject_really_used == REALLY_USED )
  140.     reject = true;
  141.     else if ( reject_really_used == REALLY_NOT_USED )
  142.     reject = false;
  143.  
  144.     if ( performance_report )
  145.     {
  146.     if ( interactive )
  147.         fprintf( stderr,
  148.              "-I (interactive) entails a minor performance penalty\n" );
  149.  
  150.     if ( yymore_used )
  151.         fprintf( stderr, "yymore() entails a minor performance penalty\n" );
  152.  
  153.     if ( reject )
  154.         fprintf( stderr, "REJECT entails a large performance penalty\n" );
  155.  
  156.     if ( variable_trailing_context_rules )
  157.         fprintf( stderr,
  158. "Variable trailing context rules entail a large performance penalty\n" );
  159.     }
  160.  
  161.     if ( reject )
  162.     real_reject = true;
  163.  
  164.     if ( variable_trailing_context_rules )
  165.     reject = true;
  166.  
  167.     if ( (fulltbl || fullspd) && reject )
  168.     {
  169.     if ( real_reject )
  170.         flexerror( "REJECT cannot be used with -f or -F" );
  171.     else
  172.         flexerror(
  173.     "variable trailing context rules cannot be used with -f or -F" );
  174.     }
  175.  
  176.     ntod();
  177.  
  178.     /* generate the C state transition tables from the DFA */
  179.     make_tables();
  180.  
  181.     /* note, flexend does not return.  It exits with its argument as status. */
  182.  
  183.     flexend( 0 );
  184.  
  185.     /*NOTREACHED*/
  186.     }
  187.  
  188.  
  189. /* flexend - terminate flex
  190.  *
  191.  * synopsis
  192.  *    int status;
  193.  *    flexend( status );
  194.  *
  195.  *    status is exit status.
  196.  *
  197.  * note
  198.  *    This routine does not return.
  199.  */
  200.  
  201. void flexend( status )
  202. int status;
  203.  
  204.     {
  205.     int tblsiz;
  206.     char *flex_gettime();
  207.  
  208.     if ( skelfile != NULL )
  209.     {
  210.     if ( ferror( skelfile ) )
  211.         flexfatal( "error occurred when writing skeleton file" );
  212.  
  213.     else if ( fclose( skelfile ) )
  214.         flexfatal( "error occurred when closing skeleton file" );
  215.     }
  216.  
  217.     if ( temp_action_file )
  218.     {
  219.     if ( ferror( temp_action_file ) )
  220.         flexfatal( "error occurred when writing temporary action file" );
  221.  
  222.     else if ( fclose( temp_action_file ) )
  223.         flexfatal( "error occurred when closing temporary action file" );
  224.  
  225.     else if ( unlink( action_file_name ) )
  226.         flexfatal( "error occurred when deleting temporary action file" );
  227.     }
  228.  
  229.     if ( status != 0 && outfile_created )
  230.     {
  231.     if ( ferror( stdout ) )
  232.         flexfatal( "error occurred when writing output file" );
  233.  
  234.     else if ( fclose( stdout ) )
  235.         flexfatal( "error occurred when closing output file" );
  236.  
  237.     else if ( unlink( outfile ) )
  238.         flexfatal( "error occurred when deleting output file" );
  239.     }
  240.  
  241.     if ( backtrack_report && backtrack_file )
  242.     {
  243.     if ( num_backtracking == 0 )
  244.         fprintf( backtrack_file, "No backtracking.\n" );
  245.     else if ( fullspd || fulltbl )
  246.         fprintf( backtrack_file,
  247.              "%d backtracking (non-accepting) states.\n",
  248.              num_backtracking );
  249.     else
  250.         fprintf( backtrack_file, "Compressed tables always backtrack.\n" );
  251.  
  252.     if ( ferror( backtrack_file ) )
  253.         flexfatal( "error occurred when writing backtracking file" );
  254.  
  255.     else if ( fclose( backtrack_file ) )
  256.         flexfatal( "error occurred when closing backtracking file" );
  257.     }
  258.  
  259.     if ( printstats )
  260.     {
  261.     endtime = flex_gettime();
  262.  
  263.     fprintf( stderr, "%s version %s usage statistics:\n", program_name,
  264.          flex_version );
  265.     fprintf( stderr, "  started at %s, finished at %s\n",
  266.          starttime, endtime );
  267.  
  268.     fprintf( stderr, "  scanner options: -" );
  269.  
  270.     if ( backtrack_report )
  271.         putc( 'b', stderr );
  272.     if ( ddebug )
  273.         putc( 'd', stderr );
  274.     if ( interactive )
  275.         putc( 'I', stderr );
  276.     if ( caseins )
  277.         putc( 'i', stderr );
  278.     if ( ! gen_line_dirs )
  279.         putc( 'L', stderr );
  280.     if ( performance_report )
  281.         putc( 'p', stderr );
  282.     if ( spprdflt )
  283.         putc( 's', stderr );
  284.     if ( use_stdout )
  285.         putc( 't', stderr );
  286.     if ( trace )
  287.         putc( 'T', stderr );
  288.     if ( printstats )
  289.         putc( 'v', stderr );    /* always true! */
  290.     if ( csize == 256 )
  291.         putc( '8', stderr );
  292.  
  293.     fprintf( stderr, " -C" );
  294.  
  295.     if ( fulltbl )
  296.         putc( 'f', stderr );
  297.     if ( fullspd )
  298.         putc( 'F', stderr );
  299.     if ( useecs )
  300.         putc( 'e', stderr );
  301.     if ( usemecs )
  302.         putc( 'm', stderr );
  303.  
  304.     if ( strcmp( skelname, DEFAULT_SKELETON_FILE ) )
  305.         fprintf( stderr, " -S%s", skelname );
  306.  
  307.     putc( '\n', stderr );
  308.  
  309.     fprintf( stderr, "  %d/%d NFA states\n", lastnfa, current_mns );
  310.     fprintf( stderr, "  %d/%d DFA states (%d words)\n", lastdfa,
  311.          current_max_dfas, totnst );
  312.     fprintf( stderr,
  313.          "  %d rules\n", num_rules - 1 /* - 1 for def. rule */ );
  314.  
  315.     if ( num_backtracking == 0 )
  316.         fprintf( stderr, "  No backtracking\n" );
  317.     else if ( fullspd || fulltbl )
  318.         fprintf( stderr, "  %d backtracking (non-accepting) states\n",
  319.              num_backtracking );
  320.     else
  321.         fprintf( stderr, "  compressed tables always backtrack\n" );
  322.  
  323.     if ( bol_needed )
  324.         fprintf( stderr, "  Beginning-of-line patterns used\n" );
  325.  
  326.     fprintf( stderr, "  %d/%d start conditions\n", lastsc,
  327.          current_max_scs );
  328.     fprintf( stderr, "  %d epsilon states, %d double epsilon states\n",
  329.          numeps, eps2 );
  330.  
  331.     if ( lastccl == 0 )
  332.         fprintf( stderr, "  no character classes\n" );
  333.     else
  334.         fprintf( stderr,
  335.     "  %d/%d character classes needed %d/%d words of storage, %d reused\n",
  336.              lastccl, current_maxccls,
  337.              cclmap[lastccl] + ccllen[lastccl],
  338.              current_max_ccl_tbl_size, cclreuse );
  339.  
  340.     fprintf( stderr, "  %d state/nextstate pairs created\n", numsnpairs );
  341.     fprintf( stderr, "  %d/%d unique/duplicate transitions\n",
  342.          numuniq, numdup );
  343.  
  344.     if ( fulltbl )
  345.         {
  346.         tblsiz = lastdfa * numecs;
  347.         fprintf( stderr, "  %d table entries\n", tblsiz );
  348.         }
  349.  
  350.     else
  351.         {
  352.         tblsiz = 2 * (lastdfa + numtemps) + 2 * tblend;
  353.  
  354.         fprintf( stderr, "  %d/%d base-def entries created\n",
  355.              lastdfa + numtemps, current_max_dfas );
  356.         fprintf( stderr, "  %d/%d (peak %d) nxt-chk entries created\n",
  357.              tblend, current_max_xpairs, peakpairs );
  358.         fprintf( stderr,
  359.              "  %d/%d (peak %d) template nxt-chk entries created\n",
  360.              numtemps * nummecs, current_max_template_xpairs,
  361.              numtemps * numecs );
  362.         fprintf( stderr, "  %d empty table entries\n", nummt );
  363.         fprintf( stderr, "  %d protos created\n", numprots );
  364.         fprintf( stderr, "  %d templates created, %d uses\n",
  365.              numtemps, tmpuses );
  366.         }
  367.  
  368.     if ( useecs )
  369.         {
  370.         tblsiz = tblsiz + csize;
  371.         fprintf( stderr, "  %d/%d equivalence classes created\n",
  372.              numecs, csize );
  373.         }
  374.  
  375.     if ( usemecs )
  376.         {
  377.         tblsiz = tblsiz + numecs;
  378.         fprintf( stderr, "  %d/%d meta-equivalence classes created\n",
  379.              nummecs, csize );
  380.         }
  381.  
  382.     fprintf( stderr, "  %d (%d saved) hash collisions, %d DFAs equal\n",
  383.          hshcol, hshsave, dfaeql );
  384.     fprintf( stderr, "  %d sets of reallocations needed\n", num_reallocs );
  385.     fprintf( stderr, "  %d total table entries needed\n", tblsiz );
  386.     }
  387.  
  388. #ifndef VMS
  389.     exit( status );
  390. #else
  391.     exit( status + 1 );
  392. #endif
  393.     }
  394.  
  395.  
  396. /* flexinit - initialize flex
  397.  *
  398.  * synopsis
  399.  *    int argc;
  400.  *    char **argv;
  401.  *    flexinit( argc, argv );
  402.  */
  403.  
  404. void flexinit( argc, argv )
  405. int argc;
  406. char **argv;
  407.  
  408.     {
  409.     int i, sawcmpflag;
  410.     char *arg, *flex_gettime(), *mktemp();
  411.  
  412.     printstats = syntaxerror = trace = spprdflt = interactive = caseins = false;
  413.     backtrack_report = performance_report = ddebug = fulltbl = fullspd = false;
  414.     yymore_used = continued_action = reject = false;
  415.     yymore_really_used = reject_really_used = false;
  416.     gen_line_dirs = usemecs = useecs = true;
  417.  
  418.     sawcmpflag = false;
  419.     use_stdout = false;
  420.  
  421.     csize = DEFAULT_CSIZE;
  422.  
  423.     program_name = argv[0];
  424.  
  425.     /* read flags */
  426.     for ( --argc, ++argv; argc ; --argc, ++argv )
  427.     {
  428.     if ( argv[0][0] != '-' || argv[0][1] == '\0' )
  429.         break;
  430.  
  431.     arg = argv[0];
  432.  
  433.     for ( i = 1; arg[i] != '\0'; ++i )
  434.         switch ( arg[i] )
  435.         {
  436.         case 'b':
  437.             backtrack_report = true;
  438.             break;
  439.  
  440.         case 'c':
  441.             fprintf( stderr,
  442.     "%s: Assuming use of deprecated -c flag is really intended to be -C\n",
  443.                  program_name );
  444.  
  445.             /* fall through */
  446.  
  447.         case 'C':
  448.             if ( i != 1 )
  449.             flexerror( "-C flag must be given separately" );
  450.  
  451.             if ( ! sawcmpflag )
  452.             {
  453.             useecs = false;
  454.             usemecs = false;
  455.             fulltbl = false;
  456.             sawcmpflag = true;
  457.             }
  458.  
  459.             for ( ++i; arg[i] != '\0'; ++i )
  460.             switch ( arg[i] )
  461.                 {
  462.                 case 'e':
  463.                 useecs = true;
  464.                 break;
  465.  
  466.                 case 'F':
  467.                 fullspd = true;
  468.                 break;
  469.  
  470.                 case 'f':
  471.                 fulltbl = true;
  472.                 break;
  473.  
  474.                 case 'm':
  475.                 usemecs = true;
  476.                 break;
  477.  
  478.                 default:
  479.                 lerrif( "unknown -C option '%c'",
  480.                     (int) arg[i] );
  481.                 break;
  482.                 }
  483.  
  484.             goto get_next_arg;
  485.  
  486.         case 'd':
  487.             ddebug = true;
  488.             break;
  489.  
  490.         case 'f':
  491.             useecs = usemecs = false;
  492.             fulltbl = true;
  493.             break;
  494.  
  495.         case 'F':
  496.             useecs = usemecs = false;
  497.             fullspd = true;
  498.             break;
  499.  
  500.         case 'I':
  501.             interactive = true;
  502.             break;
  503.  
  504.         case 'i':
  505.             caseins = true;
  506.             break;
  507.  
  508.         case 'L':
  509.             gen_line_dirs = false;
  510.             break;
  511.  
  512.         case 'n':
  513.             /* stupid do-nothing deprecated option */
  514.             break;
  515.  
  516.         case 'p':
  517.             performance_report = true;
  518.             break;
  519.  
  520.         case 'S':
  521.             if ( i != 1 )
  522.             flexerror( "-S flag must be given separately" );
  523.  
  524.             skelname = arg + i + 1;
  525.             goto get_next_arg;
  526.  
  527.         case 's':
  528.             spprdflt = true;
  529.             break;
  530.  
  531.         case 't':
  532.             use_stdout = true;
  533.             break;
  534.  
  535.         case 'T':
  536.             trace = true;
  537.             break;
  538.  
  539.         case 'v':
  540.             printstats = true;
  541.             break;
  542.  
  543.         case '8':
  544.             csize = CSIZE;
  545.             break;
  546.  
  547.         default:
  548.             lerrif( "unknown flag '%c'", (int) arg[i] );
  549.             break;
  550.         }
  551.  
  552. get_next_arg: /* used by -C and -S flags in lieu of a "continue 2" control */
  553.     ;
  554.     }
  555.  
  556.     if ( (fulltbl || fullspd) && usemecs )
  557.     flexerror( "full table and -Cm don't make sense together" );
  558.  
  559.     if ( (fulltbl || fullspd) && interactive )
  560.     flexerror( "full table and -I are (currently) incompatible" );
  561.  
  562.     if ( fulltbl && fullspd )
  563.     flexerror( "full table and -F are mutually exclusive" );
  564.  
  565.     if ( ! skelname )
  566.     {
  567.     static char skeleton_name_storage[400];
  568.  
  569.     skelname = skeleton_name_storage;
  570.     (void) strcpy( skelname, DEFAULT_SKELETON_FILE );
  571.     }
  572.  
  573.     if ( ! use_stdout )
  574.     {
  575.     FILE *prev_stdout = freopen( outfile, "w", stdout );
  576.  
  577.     if ( prev_stdout == NULL )
  578.         lerrsf( "could not create %s", outfile );
  579.  
  580.     outfile_created = 1;
  581.     }
  582.  
  583.     num_input_files = argc;
  584.     input_files = argv;
  585.     set_input_file( num_input_files > 0 ? input_files[0] : NULL );
  586.  
  587.     if ( backtrack_report )
  588.     {
  589. #ifndef SHORT_FILE_NAMES
  590.     backtrack_file = fopen( "lex.backtrack", "w" );
  591. #else
  592.     backtrack_file = fopen( "lex.bck", "w" );
  593. #endif
  594.  
  595.     if ( backtrack_file == NULL )
  596.         flexerror( "could not create lex.backtrack" );
  597.     }
  598.  
  599.     else
  600.     backtrack_file = NULL;
  601.  
  602.  
  603.     lastccl = 0;
  604.     lastsc = 0;
  605.  
  606.     /* initialize the statistics */
  607.     starttime = flex_gettime();
  608.  
  609.     if ( (skelfile = fopen( skelname, "r" )) == NULL )
  610.     lerrsf( "can't open skeleton file %s", skelname );
  611.  
  612. #ifdef SYS_V
  613.     action_file_name = tmpnam( NULL );
  614. #endif
  615.  
  616.     if ( action_file_name == NULL )
  617.     {
  618.     static char temp_action_file_name[32];
  619.  
  620. #ifdef AMIGA
  621.     (void) strcpy( temp_action_file_name, TmpFileName("t:flex") );
  622. #else
  623. #ifndef SHORT_FILE_NAMES
  624.     (void) strcpy( temp_action_file_name, "/tmp/flexXXXXXX" );
  625. #else
  626.     (void) strcpy( temp_action_file_name, "flexXXXXXX.tmp" );
  627. #endif
  628.     (void) mktemp( temp_action_file_name );
  629. #endif
  630.  
  631.     action_file_name = temp_action_file_name;
  632.     }
  633.  
  634.     if ( (temp_action_file = fopen( action_file_name, "w" )) == NULL )
  635.     lerrsf( "can't open temporary action file %s", action_file_name );
  636.  
  637.     lastdfa = lastnfa = num_rules = numas = numsnpairs = tmpuses = 0;
  638.     numecs = numeps = eps2 = num_reallocs = hshcol = dfaeql = totnst = 0;
  639.     numuniq = numdup = hshsave = eofseen = datapos = dataline = 0;
  640.     num_backtracking = onesp = numprots = 0;
  641.     variable_trailing_context_rules = bol_needed = false;
  642.  
  643.     linenum = sectnum = 1;
  644.     firstprot = NIL;
  645.  
  646.     /* used in mkprot() so that the first proto goes in slot 1
  647.      * of the proto queue
  648.      */
  649.     lastprot = 1;
  650.  
  651.     if ( useecs )
  652.     { /* set up doubly-linked equivalence classes */
  653.     /* We loop all the way up to csize, since ecgroup[csize] is the
  654.      * position used for NUL characters
  655.      */
  656.     ecgroup[1] = NIL;
  657.  
  658.     for ( i = 2; i <= csize; ++i )
  659.         {
  660.         ecgroup[i] = i - 1;
  661.         nextecm[i - 1] = i;
  662.         }
  663.  
  664.     nextecm[csize] = NIL;
  665.     }
  666.  
  667.     else
  668.     { /* put everything in its own equivalence class */
  669.     for ( i = 1; i <= csize; ++i )
  670.         {
  671.         ecgroup[i] = i;
  672.         nextecm[i] = BAD_SUBSCRIPT;    /* to catch errors */
  673.         }
  674.     }
  675.  
  676.     set_up_initial_allocations();
  677.     }
  678.  
  679.  
  680. /* readin - read in the rules section of the input file(s)
  681.  *
  682.  * synopsis
  683.  *    readin();
  684.  */
  685.  
  686. void readin()
  687.  
  688.     {
  689.     skelout();
  690.  
  691.     if ( ddebug )
  692.     puts( "#define FLEX_DEBUG" );
  693.  
  694.     if ( csize == 256 )
  695.     puts( "#define YY_CHAR unsigned char" );
  696.     else
  697.     puts( "#define YY_CHAR char" );
  698.  
  699.     line_directive_out( stdout );
  700.  
  701.     if ( yyparse() )
  702.     {
  703.     pinpoint_message( "fatal parse error" );
  704.     flexend( 1 );
  705.     }
  706.  
  707.     if ( xlation )
  708.     {
  709.     numecs = ecs_from_xlation( ecgroup );
  710.     useecs = true;
  711.     }
  712.  
  713.     else if ( useecs )
  714.     numecs = cre8ecs( nextecm, ecgroup, csize );
  715.  
  716.     else
  717.     numecs = csize;
  718.  
  719.     /* now map the equivalence class for NUL to its expected place */
  720.     ecgroup[0] = ecgroup[csize];
  721.     NUL_ec = abs( ecgroup[0] );
  722.  
  723.     if ( useecs )
  724.     ccl2ecl();
  725.     }
  726.  
  727.  
  728.  
  729. /* set_up_initial_allocations - allocate memory for internal tables */
  730.  
  731. void set_up_initial_allocations()
  732.  
  733.     {
  734.     current_mns = INITIAL_MNS;
  735.     firstst = allocate_integer_array( current_mns );
  736.     lastst = allocate_integer_array( current_mns );
  737.     finalst = allocate_integer_array( current_mns );
  738.     transchar = allocate_integer_array( current_mns );
  739.     trans1 = allocate_integer_array( current_mns );
  740.     trans2 = allocate_integer_array( current_mns );
  741.     accptnum = allocate_integer_array( current_mns );
  742.     assoc_rule = allocate_integer_array( current_mns );
  743.     state_type = allocate_integer_array( current_mns );
  744.  
  745.     current_max_rules = INITIAL_MAX_RULES;
  746.     rule_type = allocate_integer_array( current_max_rules );
  747.     rule_linenum = allocate_integer_array( current_max_rules );
  748.  
  749.     current_max_scs = INITIAL_MAX_SCS;
  750.     scset = allocate_integer_array( current_max_scs );
  751.     scbol = allocate_integer_array( current_max_scs );
  752.     scxclu = allocate_integer_array( current_max_scs );
  753.     sceof = allocate_integer_array( current_max_scs );
  754.     scname = allocate_char_ptr_array( current_max_scs );
  755.     actvsc = allocate_integer_array( current_max_scs );
  756.  
  757.     current_maxccls = INITIAL_MAX_CCLS;
  758.     cclmap = allocate_integer_array( current_maxccls );
  759.     ccllen = allocate_integer_array( current_maxccls );
  760.     cclng = allocate_integer_array( current_maxccls );
  761.  
  762.     current_max_ccl_tbl_size = INITIAL_MAX_CCL_TBL_SIZE;
  763.     ccltbl = allocate_character_array( current_max_ccl_tbl_size );
  764.  
  765.     current_max_dfa_size = INITIAL_MAX_DFA_SIZE;
  766.  
  767.     current_max_xpairs = INITIAL_MAX_XPAIRS;
  768.     nxt = allocate_integer_array( current_max_xpairs );
  769.     chk = allocate_integer_array( current_max_xpairs );
  770.  
  771.     current_max_template_xpairs = INITIAL_MAX_TEMPLATE_XPAIRS;
  772.     tnxt = allocate_integer_array( current_max_template_xpairs );
  773.  
  774.     current_max_dfas = INITIAL_MAX_DFAS;
  775.     base = allocate_integer_array( current_max_dfas );
  776.     def = allocate_integer_array( current_max_dfas );
  777.     dfasiz = allocate_integer_array( current_max_dfas );
  778.     accsiz = allocate_integer_array( current_max_dfas );
  779.     dhash = allocate_integer_array( current_max_dfas );
  780.     dss = allocate_int_ptr_array( current_max_dfas );
  781.     dfaacc = allocate_dfaacc_union( current_max_dfas );
  782.  
  783.     nultrans = (int *) 0;
  784.     }
  785.